package com.scy;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class Demo06 {
    //服务端
    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(11000);
        System.out.println("等待客户端连接...");
        Socket socket = ss.accept();
        //获取输入流
        InputStream is = socket.getInputStream();
        byte[] bytes = new byte[1024];
        int len;
        while ((len=is.read(bytes))!=-1){
            String s = new String(bytes, 0, len);
            System.out.println("接收的数据为:"+s);
        }
        //关连接
        socket.close();
        ss.close();
    }
}
